package thinking.exception;

/**
 * Created by Zhu Qinxiang on 2016/9/15.
 */
class BaseBallException extends Exception { }
class Foul extends BaseBallException { }
class Strike extends BaseBallException { }
abstract class Inning {
    public Inning() throws BaseBallException {}
    public void event() throws BaseBallException {
    }
    public abstract void atBat() throws Strike, Foul;
    public void walk() {}
}

class StormException extends Exception { }
class RainedOut extends StormException { }
class PopFoul extends Foul { }

interface Storm {
    public void event() throws RainedOut;
    public void rainHard() throws RainedOut;
}
public class StormyInning extends Inning implements Storm {
    public StormyInning() throws RainedOut, BaseBallException{
    }
    public StormyInning(String s) throws Foul, BaseBallException { }

    @Override
    public void rainHard() throws RainedOut {

    }

    @Override
    public void event() {
    }

    @Override
    public void atBat() throws PopFoul {
    }
    public static void main(String[] args) {
        try {
            StormyInning si = new StormyInning();
            si.atBat();
        } catch (PopFoul e) {
            System.out.println("Pop foul");
        } catch (RainedOut e) {
            System.out.println("Rained out");
        } catch (BaseBallException e) {
            System.out.println("Generic baseball exception");
        }

        try {
            Inning i = new StormyInning();
            i.atBat();
        } catch (Strike e) {
            System.out.println("Strike");
        } catch (PopFoul e) {
            System.out.println("Pop foul");
        } catch (RainedOut e) {
            System.out.println("Rained out");
        } catch (BaseBallException e) {
            System.out.println("Generic baseball exception");
        }
    }
}
